define(["jquery"], function($) {
    (function($) {

        $.mobile = $.extend({}, {
            loading: function(type) {
                console.log('mobile fake : loading '+type);
            },
            changePageLast: '',
            changePage: function($hash, $params) {

                console.log('mobile fake : changePage hash : ' + $hash, $params);

                $hash = $params.hash || $hash;
                $notChangeHash = $params.notChangeHash || false;
                $changeHash = $params.changeHash || false;

                $(".modal_place>div").modal('hide');
                $('.modal-backdrop').remove();


                if ($hash !== this.changePageLast || $hash === '#wykres') {
                    this.changePageLast = $hash;
                    $("div[data-role='page']").css('display', 'none');
                    $($hash).css('display', '');
                    if ($changeHash) {
                        if (location.hash == $hash) {
							$hash += '?x='+Math.random();
						}
						console.log('zmiana hasha na ' + $hash);
                        location.hash = $hash;
                    }
                    return false;
                }
            }
        });

        // fix close modal
        $('body').on('hidden.bs.modal', '.modal_place>div', function(e) {
            $('.modal-backdrop').remove();
        });

    }(jQuery));

    console.log('fake mobile is loaded');
});